`ifndef AXI_DEFINE_H
`define AXI_DEFINE_H

`define AXI_ADDR_WIDTH 32
`define AXI_DATA_WIDTH 32

typedef logic [`AXI_ADDR_WIDTH-1:0] ysyx_addr_t;
typedef logic [`AXI_DATA_WIDTH-1:0] ysyx_data_t;
typedef logic [(`AXI_DATA_WIDTH/8)-1:0] ysyx_strb_t;
typedef logic [1:0] ysyx_resp_t;
typedef logic [3:0] ysyx_id_t;
typedef logic [7:0] ysyx_len_t;
typedef logic [2:0] ysyx_size_t;
typedef logic [1:0] ysyx_burst_t;


typedef enum logic [2:0] {
    S_IDLE,
    AR_WAIT,
    R_RECV
} rstate_t;

typedef enum logic [2:0] {
    S_IDLE_,
    AW_WAIT,
    W_RECV
} wstate_t;

    // Arbiter state
typedef enum logic [1:0] {
    IDLE,
    MASTER_0,
    MASTER_1
} arb_state_t;


`define OKAY 2'b00 // transfer成功
`define EXOKAY 2'b01 // transfer部分成功，发生了可恢复的错误
`define SLVERR 2'b10 // transfer不成功，发生了不可恢复的错误
`define DECERR 2'b11 // transfer失败，发生了解码错误

//MASTER
typedef struct packed {
    ysyx_id_t awid;
    ysyx_len_t awlen;
    ysyx_size_t awsize;
    ysyx_burst_t awburst;

    logic wlast;
} axi_master_write_out_t;

typedef struct packed {
    ysyx_id_t bid;
} axi_master_write_in_t;


typedef struct packed {
    ysyx_id_t arid;
    ysyx_len_t arlen;
    ysyx_size_t arsize;
    ysyx_burst_t arburst;
} axi_master_read_out_t;

typedef struct packed {
    ysyx_id_t rid;
    logic rlast;
} axi_master_read_in_t;


// SLAVE
typedef struct packed {
    ysyx_id_t awid;
    ysyx_len_t awlen;
    ysyx_size_t awsize;
    ysyx_burst_t awburst;

    logic wlast;
} axi_slave_write_in_t;

typedef struct packed {
    ysyx_id_t bid;
} axi_slave_write_out_t;

typedef struct packed {
    ysyx_id_t arid;
    ysyx_len_t arlen;
    ysyx_size_t arsize;
    ysyx_burst_t arburst;
} axi_slave_read_in_t;

typedef struct packed {
    ysyx_id_t rid;
    logic rlast;
} axi_slave_read_out_t;

`endif // AXI_DEFINE_H
